package com.example.factory.shape;

import com.example.factory.shape.impl.Circle;
import com.example.factory.shape.impl.Rectangle;
import com.example.factory.shape.impl.Square;
import org.springframework.util.StringUtils;

/**
 * @Description TODO
 * @Date 2021/10/20 8:30
 * @Author ZhangJi
 * @Version 1.0
 */
public class ShapeFactory {

  public Shape getShapeByType(String type){

    if (!StringUtils.hasLength(type)){
      return null;
    }
    switch (type){
      case "Rectangle":
        return new Rectangle();
      case "Circle":
        return new Circle();
      case "Square":
        return new Square();
      default:
        return null;
    }

  }

}
